package 代码记录.指定公司代码练习记录.西安.分值100分未做;

import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

/**
 * @author zx
 * @create 2023-07-09 16:03
 * 这个题有难度，还没看懂，代码好复杂
 */
public class AI识别面板 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());

        int[][] arr = new int[n][4];
        for (int i = 0; i < n; i++) {
            String[] temp = scanner.nextLine().split(" ");
            int id = Integer.parseInt(temp[0]);
            int x1 = Integer.parseInt(temp[1]);
            int y1 = Integer.parseInt(temp[2]);
            int x2 = Integer.parseInt(temp[3]);
            int y2 = Integer.parseInt(temp[4]);
            arr[i] = new int[]{id, (x1 + x2) / 2, (y1 + y2) / 2, (x2 - x1) / 2};
        }

        Arrays.sort(arr, Comparator.comparingInt(a -> a[2]));

        StringBuilder result = new StringBuilder();
        int rowStartIndex = 0;
        for (int i = 1; i < n; i++) {
            if (arr[i][2] - arr[rowStartIndex][2] > arr[rowStartIndex][3]) {
                Arrays.sort(arr, rowStartIndex, i, Comparator.comparingInt(a -> a[1]));
                for (int j = rowStartIndex; j < i; j++) {
                    result.append(arr[j][0]).append(" ");
                }
                rowStartIndex = i;
            }
        }

        Arrays.sort(arr, rowStartIndex, n, Comparator.comparingInt(a -> a[1]));
        for (int i = rowStartIndex; i < n; i++) {
            result.append(arr[i][0]).append(" ");
        }

        System.out.println(result.toString().trim());
    }
}
